{* $Id$ *}
{include_core file="admin/lib/header.html" title="积分规则添加"}
<div class="page-header border-bottom clearfix">
  <h2 class="left">积分规则管理{$is_edit}<span>添加积分规则</span></h2>
  <a href="{AnUrl('score_rule/admin')}" class="btn btn-default btn-sm right">&lt;&nbsp;返回积分规则列表</a>
</div>
<!--start:积分规则新增-->
<div class="add-form">
  <form action="{if $score_rule}{AnUrl('score_rule/admin/save')}{else}{AnUrl('score_rule/admin/create')}{/if}" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$score_rule.id}">
    <table class="table" cellpadding="0" cellspacing="0">
      <tr>
        <th><label for="" class="add-f-label">积分规则问题：</label></th>
        <td>
          <input name="score_rule[question]" style="width:490px;" type="text" class="add-f-ipt1" value="{$score_rule.question}" >
        </td>
      </tr>
      <tr>
        <th valign="top"><label class="add-f-label" for="">积分规则解答：</label></th>
        <td>
          <textarea name="score_rule[answer]" class="add-f-area">{$score_rule.answer}</textarea>
          <!-- <div class="tips">积分规则内容会显示在相应内容的简介位置，最多输入 <span style="color:red;">80</span> 字，还可输入 <span style="color:red;">200</span> 字</div> -->
        </td>
      </tr>
      <tr>
        <th valign="top"><label class="add-f-label" for="">FAQ优先级：</label></th>
        <td>
          <input name="score_rule[sort]" style="width:100px;" type="text" size="10" class="add-f-ipt1" value="{$score_rule.sort}" >
          <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>只能填写数字,并且数字越大优先级越高,最大不超过999999999</div>
        </td>
      </tr>
      <tr><th>&nbsp;</th><td class="noborder"><button type="submit" class="btn btn-success">&nbsp;&nbsp;&nbsp;确认&nbsp;&nbsp;&nbsp;</button></td></tr>
    </table>
  </form>
</div>
<!--end:积分规则新增-->
<script>
$(function(){ 
  var checkSort = true;
  // 提交验证
  $('form').submit(function(){
    //验证
    if($('input[name="score_rule[question]"],input[name="score_rule[answer]"]').val() == ''){
      showMsg('问题或解答不能为空');
      return false;
    }
    
    if(!checkSort){
    	showMsg('优先级数字过大!请重新填写');
    	checkSort = flase;
    	return false;
    }
    
    
  });

    
  //过滤等级(去掉除了数字)
  $('input[name="score_rule[sort]"]').keyup(function(){
    var reg = /\D+/;
    $(this).val($(this).val().replace(reg, ''));
    
    //过滤长度
    if ($(this).val().length > 9) {
    	$(this).val(parseInt($(this).val().substr(0, 9)));
    	checkSort = false;
    	return false;
    } else {
    	checkSort = true;
    }
    
  });
  
  
});

</script>
{include_core file="admin/lib/footer.html"}